package com.ys.controller;  

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ys.entity.User;
import com.ys.service.impl.UserServiceImpl;  

@Controller  
public class LoginController {  
    @Autowired  
    private UserServiceImpl userService;  

@RequestMapping("/dologin.do") //url  
public String dologin(User user, Model model){  
    if(userService.doUserLogin	(user)){
        model.addAttribute("successMsg", "登陆成功！");//返回到页面所夹带的参数  
        user = userService.getUser(user.getUsername());
        model.addAttribute("user", user);  
        return "success";//返回的页面  
    }else{  
        model.addAttribute("failMsg", "用户不存在或密码错误！");  
        return "fail";  
    }     
}  
}  